// State.cpp

// Informacie o stave hry - implementacia

#include "Player/World/State.h"
#include "Player/World/World.h"

// Konstruktor
State::State(World* w) : WorldObject(w)
{
	// Simulacny cas sa nastavi na 0
	simTime = 0;
	// Ziadny hraci mod
	playMode = PM_Null;
	// Vynuluje sa skore hry
	ourScore = theirScore = 0;
}

// Kopirovaci konstruktor
State::State(const State& state) : WorldObject(state.world)
{
	simTime = state.simTime;
	playMode = state.playMode;
	ourScore = state.ourScore;
	theirScore = state.theirScore;
}

// Destruktor
State::~State()
{
}

// Operator priradenia
State& State::operator =(const State& state)
{
	// Zabezpecenie proti prepisaniu sameho seba
	if(&state == this) 
		return *this;

	// Je toto potrebne?
	WorldObject::operator =(state);

	simTime = state.simTime;
	playMode = state.playMode;
	ourScore = state.ourScore;
	theirScore = state.theirScore;

	return *this;
}
// Vykopavame my?
bool State::IsOurKickIn() const
{
	// Vsetky hracie mody, pri ktorych vykopavame my
	switch(playMode)
	{
	case PM_KickOff_Our:
	case PM_KickIn_Our:
	case PM_FreeKick_Our:
	case PM_CornerKick_Our:
	case PM_GoalKick_Our:
	case PM_AfterGoal_Our:
	case PM_Offside_Our:
	case PM_PenaltyKick_Our:
	case PM_Foul_Charge_Our:
	case PM_Foul_Push_Our:
	case PM_Foul_MultipleAttacker_Our:
	case PM_Foul_BallOut_Our:
	case PM_GoalieCatch_Our:
	case PM_Foul_Our:
	case PM_FreeKickFault_Our:
	case PM_BackPass_Our:
		return true;
	
	default:
		return false;
	}
}

// Je zastaveny simulacny cas?
bool State::IsTimeStoped() const
{
	// Vsetky hracie mody, pri ktorych je zastaveny simulacny cas
	switch(playMode)
	{
	case PM_BeforeKickOff:
	case PM_AfterGoal_Our:
	case PM_AfterGoal_Their:
		return true;
	default:
		return false;
	}
}

